<?php

//echo br(3); ###########################################################################################

	$TEMP->set_file(array('handle' => DIR_VIEW_REGISTRAR . 'studentRequest.html'));
	
	
	$urlPage 	= _GET('page');
	#SEARCH
	$search 	= _GET('search', false);
	if ( empty($search) ) {
		$search = "Search here...";
	}
	
	$getStudentListRequestCount = $STUD->getStudentListRequestCount($search); //COUNT
	
	if( $getStudentListRequest > 0 ) {
		$countNum			= 20;
		$pagenum 			= $_GET["page_no"];
		$page_rows 			= $PAGINATION->numPerRow($countNum);
		$last 				= $PAGINATION->lastCeilPerRow($getStudentListRequestCount, $page_rows);
		$pagenum 			= $PAGINATION->pageNumRow($pagenum, $last); 
		$pageLimit 			= $PAGINATION->limitRow($pagenum, $page_rows);
		
		$arrBut				= array('first' 	=> '<img src="' . DIR_IMAGES . 'pagination_first.png" title="First" border="0" />',
									'previous' 	=> '<img src="' . DIR_IMAGES . 'pagination_prev.png" title="Previous" border="0" />',
									'next' 		=> '<img src="' . DIR_IMAGES . 'pagination_next.png" title="Next" border="0" />',
									'last' 		=> '<img src="' . DIR_IMAGES . 'pagination_last.png" title="Last" border="0" />',);
		$classCSS			= array('button' 	=> 'pagination-button', 'label' 	=> 'pagination-label');
		$urlGet				= array('page' 		=> $_GET['page'], 		'search' 	=> $search);
		
		if( $getStudentListRequestCount > $countNum ) {
			$pagination 	= $PAGINATION->pagination($arrBut, $pagenum, $last, $classCSS, $urlGet);
		}
	}
		
	$studList = $STUD->getStudentListRequest($search, $pageLimit);
	
	$studListCount = count($studList);
	
	# LSITING
	if ( !empty($studList) ) {
		
		$TEMP->set_block('handle',  'students', 'studentsRow');
		$bgcolor 	= LOOPING_F0F;
		$numCount 	= 1;
			
		foreach($studList as $studListField => $studListValue) {
			
			$studID = $studListValue['stud_idPK'];
			$name	= $studListValue['last_name'] . ', ' . $studListValue['first_name'] . ' ' . $studListValue['middle_name'];
			$requestSemActive	= $STUD->getSemesterEnrollmentActive($studID);

			switch($studListValue['request_type']) {
				case 'password'			: 	$requestBut = '<span class="font-red" onclick="popupRequest(\'show\', \'StudentRequestPassword\', \''. $name . '\', \'245\', \'500\', \'' . $studID . '\');"><u>CHANGE PASSWORD</u></span>'; break;
				case 'reg_section'		:	$requestBut = '<span class="font-blue" onclick="popupRequest(\'show\', \'RequestStudentSection\', \''. $name . '\', \'180\', \'500\', \'' . $studID . '&slid=' . $requestSemActive['sem_linker_idFK'] .'\');"><u>CHANGE SECTION</u></span>'; break;
				case 'irreg_subj'		:	$requestBut = '<span class="font-blue" onclick="popupRequest(\'show\', \'IRRequestStudentSubject\', \''. $name . '\', \'180\', \'550\', \'' . $studID . '&tblr=' . $studListValue['table_request'] . '&tblid=' . $studListValue['table_id'] . '\');"><u>DROP SUBJECT</u></span>'; break;
				case 'irreg_schedule'	:	$requestBut = '<span class="font-blue" onclick="popupRequest(\'show\', \'IRRequestStudentSection\', \''. $name . '\', \'500\', \'650\', \'' . $studID . '&slid=' . $requestSemActive['sem_linker_idFK'] .'\');"><u>REQUEST SCHEDULE</u></span>'; break;
				default					: 	$requestBut = '-----------';
			}
			
			$TEMP->set_var(array('stud_id' 		=> $studID,
								 'stud_no' 		=> $studListValue['stud_no'],
								 'name' 		=> $name,
								 'email'		=> $studListValue['email'],
								 'request'		=> $requestBut,
								 'bgcolor'		=> $bgcolor,
								 'numbering'	=> $numCount . '.',
								));
								
			$TEMP->parse('studentsRow', 'students', true);
			$bgcolor = ($bgcolor == LOOPING_F0F) ? LOOPING_FFF : LOOPING_F0F;
			$numCount++;
		}
	}
	else {
		$TEMP->set_var(array('stud_id' 		=> '',
							 'stud_no' 		=> '',
							 'name' 		=> 'No Record Found.',
							 'email'		=> '',
							 'request'		=> '',
							 'change'		=> '',
							 'bgcolor'		=> '',
							 'numbering'	=> '',
							));
	}
	$TEMP->set_var(array('reg_sub_menu'		=> $pageLib->registrarSubMenu(DIR_IMAGES),
					     'pagination'		=> $pagination,
						 'results'			=> "<strong>" . $getStudentListRequestCount . "</strong> results",
						 'urlPage'			=> $urlPage,
						 'search' 			=> $search,
						));
?>